//
//  homePageViewController.m
//  MyFairLady
//
//  Created by dlios on 15-5-21.
//  Copyright (c) 2015年 蓝鸥. All rights reserved.
//

#import "homePageViewController.h"

@interface homePageViewController ()

@end

@implementation homePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"首页";
    self.view.backgroundColor = [UIColor colorWithWhite:0.902 alpha:1.000];
    UIImageView *homeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 350)];
    homeImageView.backgroundColor = [UIColor redColor];
    [self.view addSubview:homeImageView];
    homeImageView.userInteractionEnabled = YES;

    UIButton *homeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    homeButton.frame = CGRectMake(30, 240, 320, 40);
    homeButton.backgroundColor = [UIColor whiteColor];
    [homeButton setTitle:@"请输入食物名称" forState:UIControlStateNormal];
    [homeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    UIImage *homeImage = [UIImage imageNamed:@"iconfont-sousuo"];
    [homeButton setImage:homeImage forState:UIControlStateNormal];
    homeButton.layer.borderWidth = 1;
    homeButton.layer.borderColor = [UIColor clearColor].CGColor;
    homeButton.layer.masksToBounds = YES;
    homeButton.layer.cornerRadius = 4;
    [self.view addSubview:homeButton];
    [homeButton addTarget:self action:@selector(touchHomeButton) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *homeLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, homeImageView.frame.size.height, self.view.frame.size.width, 130)];
    homeLabel.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:homeLabel];
    
    myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 480, self.view.frame.size.width, self.view.frame.size.height - 480)];
    myScrollView.backgroundColor = [UIColor whiteColor];
    myScrollView.contentSize = CGSizeMake(self.view.frame.size.width * 4, myScrollView.frame.size.height);
    [myScrollView setContentOffset:CGPointMake(0, 0)];
    myScrollView.delegate = self;
    myScrollView.pagingEnabled = YES;
    [self.view addSubview:myScrollView];
    myScrollView.showsHorizontalScrollIndicator = NO;
    myScrollView.showsVerticalScrollIndicator = NO;
    
    
    
    for (int i = 0; i < 4; i++) {
        NSString *str = [NSString stringWithFormat:@"image%d.jpg", i];
        UIImage *image = [UIImage imageNamed:str];
        UIImageView *myimageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * i, 0, self.view.frame.size.width, self.view.frame.size.height - 480)];
        myimageView.image = image;
        [myScrollView addSubview:myimageView];
        [myimageView release];
    }
    
    

    
    
    [myScrollView release];
    [homeButton release];
    [homeImageView release];
    [homeLabel release];
}

#pragma mark button的点击跳转方法
- (void)touchHomeButton
{
    FirstViewController *first = [[FirstViewController alloc] init];
    [self.navigationController pushViewController:first animated:NO];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"%f", scrollView.contentOffset.x);
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
